using System;

namespace Crawler
{
	/// <summary>
	/// Understands the primary field of the DownloadStore
	/// </summary>
	public class Key : IKey
	{
		String key;
		public static IKey NULL_KEY = NullKey.NULL_KEY;

		public Key(String key) {
			this.key = key;
		}

		public override bool Equals(object obj) {
			return ((Key)obj).key == this.key; 
		}

		public override int GetHashCode() {
			return key.GetHashCode();
		}

		public override string ToString() {
			return this.key;
		}


		/// <summary>
		/// Understands the null pattern for a key
		/// </summary>
		private class NullKey : IKey {
		
			public static IKey NULL_KEY = new NullKey();

			private NullKey()
			{
			}

			#region IKey Members

			public bool Equals(object obj) {
				return false;
			}

			public int GetHashCode() {
				return 0;
			}

			public string ToString()
			{
				return "";	
			}

			#endregion

		}

	}
}
